package collections;

import java.util.HashMap;
import java.util.Map;

/**
 * size / isEmpty / containsKey / containsValue / get / clear
 */
public class MapTest2 {
    public static void main(String[] args) {

        Map<String , Integer> map = new HashMap<>();
        System.out.println( "size : " + map.size() + " , is empty : " + map.isEmpty() );

        map.put( "藜蒿炒腊肉" , 10 );
        map.put( "蒜苗回锅肉" , 12 );
        map.put( "土豆片回锅肉" , 12 );
        map.put( "毛血旺" , 10 );
        map.put( "蒜苗回锅肉" , 15 );//覆盖了前面的蒜苗回锅肉，value值变为15
        System.out.println( map);
        System.out.println( "size : " + map.size() + " , is empty : " + map.isEmpty() );

        System.out.println( map.containsKey( "酸辣土豆丝" ) );//false
        System.out.println( map.containsKey( "蒜苗回锅肉" ) );//true

        System.out.println( map.containsValue( 10 ) );//true
        System.out.println( map.containsValue( 20 ) );//false

        System.out.println( map.get( "毛血旺" ) );//根据 key 值 获得相对应的 value 值
        System.out.println( map.get( "土豆片回锅肉" ) );//根据 key 值 获得相对应的 value 值

        System.out.println( map );

        System.out.println("----------------------------");

        map.clear();
        System.out.println( map );

    }
}
